<template>
  <div>
    <!-- v-for 指令 -->
    <!-- 遍历数组或对象或数组对象 动态创建标签 -->
    <ul>
      <li v-for="(val, index) in arr" :key="index">{{ val }} -- {{ index }}</li>
    </ul>
    <hr />
    <ul>
      <li v-for="val in stuArr" :key="val.id">
        <p>{{ val.id }}</p>
        <p>{{ val.name }}</p>
        <p>{{ val.sex }}</p>
        <p>{{ val.hobby }}</p>
      </li>
    </ul>
    <hr />
    <ul>
      <li v-for="(val, key) in tObj" :key="key">
        <span>{{ val }} -- {{ key }}</span>
      </li>
    </ul>
    <hr />
    <li v-for="n in count" :key="n">{{ n }}</li>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: ["小明", "小欢欢", "大黄"],
      stuArr: [
        {
          id: 1001,
          name: "孙悟空",
          sex: "男",
          hobby: "吃桃子",
        },
        {
          id: 1002,
          name: "猪八戒",
          sex: "男",
          hobby: "背媳妇",
        },
      ],
      tObj: {
        name: "小黑",
        age: 18,
        class: "1期",
      },
      count: 10,
    };
  },
};
</script>

<style lang="less">
li {
  list-style: none;
  margin-bottom: 5px;
}
</style>
